package com.a2v2.online.store.database.dao.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.a2v2.online.store.database.dao.contract.INotificationEventDAO;
import com.a2v2.online.store.database.entity.NotificationEvent;
import com.a2v2.online.store.service.dto.NotificationDTO;

public class NotificationEventDAOImpl extends GenericHibernateDAO<NotificationEvent, Long>
		implements INotificationEventDAO {


	@Override
	public NotificationEvent findNotificationTemplate(NotificationDTO notificationDTO) {
		NotificationEvent notificationevent = null;
		try
		{
			Criteria criteria = this.getCurrrentSession().createCriteria(getPersistentClass());
			notificationevent = (NotificationEvent)criteria.add(Restrictions.eq("serviceName", notificationDTO.getServiceName().getServiceName()))
					                .add(Restrictions.eq("event", notificationDTO.getEvent().getEvent())).uniqueResult();
			//TODO : we need to add the criteria for PI_CODE but for the time being i am not adding this as we don't have the PI data.
			// .add(Restrictions.eq("pi_code", notificationDTO.getPiCode()))
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
		return notificationevent;
	}

}
